Skip to content

refactor(modules): replace sequencer by rollkitmngr #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented May 23, 2025

Overview

Closes: #102

  • Rename sequencer module to rollkitmngr
    • A chain can migrate to rollkit and define a list of attesters as well, this module is thus no more related only to the sequencer
  • Add state for storing migration information and the sequencer
  • Add method to track if chain is migrating and make sure restarting after upgrading works
  • Modify endblock logic to have a fast mode (no ibc) and a slow mode (with ibc) when modifying the validator set

Note: the edit of attesters after the upgrade has not been implemented yet. it will be done in a follow-up

Summary by CodeRabbit

  • New Features

    • Introduced the Rollkit Manager module to manage sequencers, attesters, and migration from CometBFT to Rollkit.
    • Added gRPC queries for migration status, current sequencer, and attesters.
    • Added governance messages to initiate migration and modify attesters.
  • Improvements

    • Clarified and expanded documentation on module capabilities and migration.
    • Updated dependency declarations for clearer requirements.
  • Refactor

    • Replaced the sequencer module with the Rollkit Manager module, consolidating sequencer and attester management.
    • Updated CLI commands and service names to align with the new module.
    • Updated internal package names and import paths from sequencer to rollkitmngr.
  • Bug Fixes

    • Enhanced validation and error handling in migration and attester editing processes.
    • Improved migration lifecycle hooks to enforce binary switch and handle IBC-enabled gradual migration.
  • Chores

    • Removed obsolete sequencer module files and interfaces.
    • Updated Makefile protobuf generation target to reflect new module paths.

Copy link
Contributor

coderabbitai bot commented May 23, 2025

"""

Walkthrough

This change removes the sequencer module and introduces a new rollkitmngr (Rollkit Manager) module, updating all related protobuf definitions, Go code, and documentation. The new module expands the scope to manage both sequencers and attesters, and implements new migration logic, gRPC queries, and governance message handling for transitioning from CometBFT to Rollkit.

Changes

Files / Groups Change Summary
Makefile, go.mod Updated proto-gen file movement to new module; made cosmossdk.io/store a direct dependency.
modules/README.md Documentation updated to describe Rollkit Manager, attesters, and migration process.
modules/proto/rollkitsdk/rollkitmngr/* (module.proto, v1/*.proto) Added new protobuf definitions for Rollkit Manager: module, queries, tx, and types, supporting sequencer, attesters, and migration.
modules/proto/rollkitsdk/sequencer/v1/* Deleted all sequencer module proto definitions (query, tx, types).
modules/rollkitmngr/* New module implementation: keeper, migration logic, gRPC query server, message server, module wiring, CLI options, and types.
modules/sequencer/* Deleted all sequencer module Go code: keeper, migration, queries, message server, keys.
modules/rollkitmngr/types/* Added new module keys, updated codec registrations, and extended types with new methods.
modules/rollkitmngr/types/expected_keepers.go Removed AccountKeeper interface; extended StakingKeeper with GetValidatorByConsAddr method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MsgServer
    participant Keeper
    participant Store
    participant StakingKeeper

    User->>MsgServer: MsgMigrateToRollkit / MsgEditAttesters
    MsgServer->>Keeper: Validate and process message
    Keeper->>Store: Set migration or attesters state
    Keeper->>StakingKeeper: (if needed) Query validator info
    MsgServer-->>User: Response

    User->>Keeper: gRPC Query (IsMigrating / Sequencer / Attesters)
    Keeper->>Store: Read migration/sequencer/attesters state
    Keeper->>StakingKeeper: (if needed) Query validators
    Keeper-->>User: Query Response

    Note over Keeper: At EndBlock/PreBlocker, Keeper manages migration process and validator updates.
Loading

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • tac0turtle
  • alpe

Poem

A hop, a skip, a module swap—
The sequencer's gone, let Rollkit pop!
Attesters join the bunny crew,
Migration logic, shiny and new.
With keys and keepers, smooth and spry,
This rabbit's code will never die!
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@julienrbrt julienrbrt mentioned this pull request May 23, 2025
5 tasks
@julienrbrt julienrbrt changed the title feat(sequencer): slowly migrate validator set [WIP] feat(sequencer): slowly migrate validator set May 23, 2025
@julienrbrt julienrbrt changed the title [WIP] feat(sequencer): slowly migrate validator set refactor(modules): replace sequencer by rollkitmngr May 28, 2025
@julienrbrt julienrbrt marked this pull request as ready for review May 28, 2025 22:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (12)
modules/rollkitmngr/types/sequencer.go (3)

32-44: Consider refactoring to reduce code duplication.

The TmConsPublicKey method for Attester is functionally correct and necessary. However, it's identical to the Sequencer.TmConsPublicKey method, creating code duplication.

Consider extracting this logic into a shared helper function:

+// tmConsPublicKeyFromAny converts a consensus public key from Any type to CometBFT public key.
+func tmConsPublicKeyFromAny(consensusPubkey *codectypes.Any) (cmtprotocrypto.PublicKey, error) {
+	pk, ok := consensusPubkey.GetCachedValue().(cryptotypes.PubKey)
+	if !ok {
+		return cmtprotocrypto.PublicKey{}, errors.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", pk)
+	}
+
+	tmPk, err := cryptocodec.ToCmtProtoPublicKey(pk)
+	if err != nil {
+		return cmtprotocrypto.PublicKey{}, err
+	}
+	return tmPk, nil
+}
+
 // TmConsPublicKey converts the Sequencer's ConsensusPubkey to a CometBFT PublicKey type.
 func (att Attester) TmConsPublicKey() (cmtprotocrypto.PublicKey, error) {
-	pk, ok := att.ConsensusPubkey.GetCachedValue().(cryptotypes.PubKey)
-	if !ok {
-		return cmtprotocrypto.PublicKey{}, errors.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", pk)
-	}
-
-	tmPk, err := cryptocodec.ToCmtProtoPublicKey(pk)
-	if err != nil {
-		return cmtprotocrypto.PublicKey{}, err
-	}
-	return tmPk, nil
+	return tmConsPublicKeyFromAny(att.ConsensusPubkey)
 }

Then apply the same refactor to the Sequencer.TmConsPublicKey method.


32-32: Fix comment inconsistency.

The comment incorrectly refers to "Sequencer's ConsensusPubkey" when it should refer to "Attester's ConsensusPubkey".

-// TmConsPublicKey converts the Sequencer's ConsensusPubkey to a CometBFT PublicKey type.
+// TmConsPublicKey converts the Attester's ConsensusPubkey to a CometBFT PublicKey type.

46-50: Code duplication in UnpackInterfaces method.

Similar to the TmConsPublicKey method, this UnpackInterfaces implementation is identical to the Sequencer version, creating unnecessary duplication.

Consider creating a shared helper function for interface unpacking as well:

+// unpackConsensusPubkey unpacks a consensus public key from Any type.
+func unpackConsensusPubkey(unpacker codectypes.AnyUnpacker, consensusPubkey *codectypes.Any) error {
+	var pk cryptotypes.PubKey
+	return unpacker.UnpackAny(consensusPubkey, &pk)
+}
+
 // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
 func (att Attester) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
-	var pk cryptotypes.PubKey
-	return unpacker.UnpackAny(att.ConsensusPubkey, &pk)
+	return unpackConsensusPubkey(unpacker, att.ConsensusPubkey)
 }
modules/README.md (1)

13-19: Consider rewording to avoid repetitive sentence structure.

The documentation is accurate and comprehensive. However, there's a minor style issue with consecutive sentences starting with "Additionally."

-Additionally, it has additional queries to get the sequencer information, and the attesters information.
+It provides queries to get the sequencer information and the attesters information.

-Additionally, when added to a CometBFT chain, the `rollkitmngr` module will handle the switch from a CometBFT validator set to a Rollkit sequencer at a given height.
+When added to a CometBFT chain, the `rollkitmngr` module will handle the switch from a CometBFT validator set to a Rollkit sequencer at a given height.
🧰 Tools
🪛 LanguageTool

[style] ~18-~18: Two successive sentences begin with the same adverb. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mation, and the attesters information. Additionally, when added to a CometBFT chain, the `r...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

modules/proto/rollkitsdk/rollkitmngr/v1/tx.proto (1)

32-35: Fix grammatical error in comment.

The comment has a grammatical error - "trigger" should be "triggers" to match the singular subject "block height".

-  // block height that trigger the rollkit migration.
+  // block height that triggers the rollkit migration.
modules/proto/rollkitsdk/rollkitmngr/v1/types.proto (1)

13-15: Fix grammatical error in comment.

Same grammatical error as in tx.proto - "trigger" should be "triggers".

-  // block height that trigger the rollkit migration.
+  // block height that triggers the rollkit migration.
modules/rollkitmngr/keeper/grpc_query.go (1)

17-17: Update comment to reflect module name change.

The comment still references "sequencer query server" but this is now the rollkitmngr module.

-// NewQueryServer creates a new instance of the sequencer query server.
+// NewQueryServer creates a new instance of the rollkitmngr query server.
modules/rollkitmngr/keeper/msg_server.go (2)

20-20: Update comment to reflect module name change.

The comment still references "sequencer MsgServer" but this is now the rollkitmngr module.

-// NewMsgServerImpl returns an implementation of sequencer MsgServer interface.
+// NewMsgServerImpl returns an implementation of rollkitmngr MsgServer interface.

54-54: Complete the EditAttesters implementation.

The method currently only validates attesters but doesn't actually edit them. The TODO comment and empty implementation suggest this is incomplete.

Would you like me to help implement the logic to update the attesters after validation, or open an issue to track this incomplete functionality?

Also applies to: 78-80

modules/rollkitmngr/keeper/keeper.go (2)

29-29: Update comment to reflect module name change.

The comment still references "sequencer Keeper" but this is now the rollkitmngr module.

-// NewKeeper creates a new sequencer Keeper instance.
+// NewKeeper creates a new rollkitmngr Keeper instance.

113-114: Consider assigning to blank identifier for clarity.

The GetKVStore result is not used. Assign to blank identifier to make the intent clearer.

 	ms := sdkCtx.MultiStore()
-	ms.GetKVStore(ibcStoreKey)
+	_ = ms.GetKVStore(ibcStoreKey)
modules/rollkitmngr/keeper/migration.go (1)

107-111: Implement the migrateOver function or remove it.

The migrateOver function is declared but not implemented. This could cause runtime panics if called.

Consider either:

  1. Implementing the gradual migration logic for IBC compatibility
  2. Removing the function if it's not needed yet
  3. Adding a feature flag to prevent accidental calls

Would you like me to help implement the gradual migration logic or suggest an alternative approach?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ceee6d and 7d85e9b.

⛔ Files ignored due to path filters (9)
  • modules/rollkitmngr/module/module.pb.go is excluded by !**/*.pb.go
  • modules/rollkitmngr/types/query.pb.go is excluded by !**/*.pb.go
  • modules/rollkitmngr/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
  • modules/rollkitmngr/types/tx.pb.go is excluded by !**/*.pb.go
  • modules/rollkitmngr/types/types.pb.go is excluded by !**/*.pb.go
  • modules/sequencer/types/query.pb.go is excluded by !**/*.pb.go
  • modules/sequencer/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
  • modules/sequencer/types/tx.pb.go is excluded by !**/*.pb.go
  • modules/sequencer/types/types.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (28)
  • Makefile (1 hunks)
  • go.mod (1 hunks)
  • modules/README.md (2 hunks)
  • modules/proto/rollkitsdk/rollkitmngr/module/v1/module.proto (1 hunks)
  • modules/proto/rollkitsdk/rollkitmngr/v1/query.proto (1 hunks)
  • modules/proto/rollkitsdk/rollkitmngr/v1/tx.proto (1 hunks)
  • modules/proto/rollkitsdk/rollkitmngr/v1/types.proto (1 hunks)
  • modules/proto/rollkitsdk/sequencer/v1/query.proto (0 hunks)
  • modules/proto/rollkitsdk/sequencer/v1/tx.proto (0 hunks)
  • modules/proto/rollkitsdk/sequencer/v1/types.proto (0 hunks)
  • modules/rollkitmngr/autocli.go (2 hunks)
  • modules/rollkitmngr/depinject.go (2 hunks)
  • modules/rollkitmngr/keeper/abci.go (1 hunks)
  • modules/rollkitmngr/keeper/grpc_query.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
  • modules/rollkitmngr/keeper/migration.go (1 hunks)
  • modules/rollkitmngr/keeper/msg_server.go (1 hunks)
  • modules/rollkitmngr/module.go (4 hunks)
  • modules/rollkitmngr/types/codec.go (1 hunks)
  • modules/rollkitmngr/types/expected_keepers.go (1 hunks)
  • modules/rollkitmngr/types/keys.go (1 hunks)
  • modules/rollkitmngr/types/sequencer.go (2 hunks)
  • modules/sequencer/keeper/abci.go (0 hunks)
  • modules/sequencer/keeper/grpc_query.go (0 hunks)
  • modules/sequencer/keeper/keeper.go (0 hunks)
  • modules/sequencer/keeper/migration.go (0 hunks)
  • modules/sequencer/keeper/msg_server.go (0 hunks)
  • modules/sequencer/types/keys.go (0 hunks)
💤 Files with no reviewable changes (9)
  • modules/sequencer/types/keys.go
  • modules/proto/rollkitsdk/sequencer/v1/types.proto
  • modules/sequencer/keeper/abci.go
  • modules/proto/rollkitsdk/sequencer/v1/tx.proto
  • modules/sequencer/keeper/keeper.go
  • modules/sequencer/keeper/msg_server.go
  • modules/sequencer/keeper/grpc_query.go
  • modules/sequencer/keeper/migration.go
  • modules/proto/rollkitsdk/sequencer/v1/query.proto
🧰 Additional context used
🧬 Code Graph Analysis (7)
modules/rollkitmngr/module.go (1)
modules/rollkitmngr/types/keys.go (1)
  • ModuleName (4-4)
modules/rollkitmngr/types/codec.go (1)
modules/rollkitmngr/types/tx.pb.go (6)
  • MsgMigrateToRollkit (35-47)
  • MsgMigrateToRollkit (51-51)
  • MsgMigrateToRollkit (52-54)
  • MsgEditAttesters (149-155)
  • MsgEditAttesters (159-159)
  • MsgEditAttesters (160-162)
modules/rollkitmngr/keeper/abci.go (1)
modules/rollkitmngr/keeper/keeper.go (1)
  • Keeper (16-27)
modules/rollkitmngr/types/sequencer.go (1)
modules/rollkitmngr/types/types.pb.go (3)
  • Attester (152-158)
  • Attester (162-162)
  • Attester (163-165)
modules/rollkitmngr/keeper/keeper.go (4)
modules/rollkitmngr/types/expected_keepers.go (2)
  • AccountKeeper (12-17)
  • StakingKeeper (20-24)
modules/rollkitmngr/types/types.pb.go (6)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
modules/rollkitmngr/types/keys.go (3)
  • SequencerKey (8-8)
  • MigrationKey (7-7)
  • ModuleName (4-4)
modules/rollkitmngr/keeper/migration.go (1)
  • IBCSmoothingFactor (14-14)
modules/rollkitmngr/keeper/msg_server.go (3)
modules/rollkitmngr/types/tx.pb.go (13)
  • MsgServer (333-338)
  • MsgMigrateToRollkit (35-47)
  • MsgMigrateToRollkit (51-51)
  • MsgMigrateToRollkit (52-54)
  • MsgMigrateToRollkitResponse (112-113)
  • MsgMigrateToRollkitResponse (117-117)
  • MsgMigrateToRollkitResponse (118-120)
  • MsgEditAttesters (149-155)
  • MsgEditAttesters (159-159)
  • MsgEditAttesters (160-162)
  • MsgEditAttestersResponse (206-207)
  • MsgEditAttestersResponse (211-211)
  • MsgEditAttestersResponse (212-214)
modules/rollkitmngr/keeper/keeper.go (1)
  • Keeper (16-27)
modules/rollkitmngr/types/types.pb.go (6)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
modules/rollkitmngr/keeper/grpc_query.go (3)
modules/rollkitmngr/types/query.pb.go (19)
  • QueryServer (405-412)
  • QueryAttestersRequest (218-219)
  • QueryAttestersRequest (223-223)
  • QueryAttestersRequest (224-226)
  • QueryAttestersResponse (255-258)
  • QueryAttestersResponse (262-262)
  • QueryAttestersResponse (263-265)
  • QueryIsMigratingRequest (34-35)
  • QueryIsMigratingRequest (39-39)
  • QueryIsMigratingRequest (40-42)
  • QueryIsMigratingResponse (71-78)
  • QueryIsMigratingResponse (82-82)
  • QueryIsMigratingResponse (83-85)
  • QuerySequencerRequest (135-136)
  • QuerySequencerRequest (140-140)
  • QuerySequencerRequest (141-143)
  • QuerySequencerResponse (172-175)
  • QuerySequencerResponse (179-179)
  • QuerySequencerResponse (180-182)
modules/rollkitmngr/keeper/keeper.go (1)
  • Keeper (16-27)
modules/rollkitmngr/types/types.pb.go (6)
  • Attester (152-158)
  • Attester (162-162)
  • Attester (163-165)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
🪛 Buf (1.54.0)
modules/proto/rollkitsdk/rollkitmngr/module/v1/module.proto

4-4: import "cosmos/app/v1alpha1/module.proto": file does not exist

(COMPILE)

modules/proto/rollkitsdk/rollkitmngr/v1/types.proto

4-4: import "amino/amino.proto": file does not exist

(COMPILE)

modules/proto/rollkitsdk/rollkitmngr/v1/query.proto

4-4: import "amino/amino.proto": file does not exist

(COMPILE)

modules/proto/rollkitsdk/rollkitmngr/v1/tx.proto

4-4: import "amino/amino.proto": file does not exist

(COMPILE)

🪛 LanguageTool
modules/README.md

[style] ~18-~18: Two successive sentences begin with the same adverb. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mation, and the attesters information. Additionally, when added to a CometBFT chain, the `r...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (30)
go.mod (1)

17-17: LGTM: Appropriate dependency promotion.

Moving cosmossdk.io/store from indirect to direct dependency is correct, as the new rollkitmngr module likely uses Cosmos SDK store interfaces directly for its expanded functionality.

modules/rollkitmngr/depinject.go (2)

1-1: LGTM: Consistent package rename.

The package name change from sequencer to rollkitmngr is properly implemented.


12-14: LGTM: Import paths correctly updated.

All import paths have been consistently updated to reference the new rollkitmngr module structure, maintaining the same functionality.

modules/rollkitmngr/types/expected_keepers.go (1)

21-21: LGTM: Well-designed interface extension.

The new GetValidatorByConsAddr method is properly designed and supports the expanded attester validation functionality in the rollkitmngr module.

modules/rollkitmngr/module.go (3)

1-1: LGTM: Package name consistently updated.

The package rename from sequencer to rollkitmngr is correctly implemented.


15-16: LGTM: Import paths properly updated.

All import paths have been consistently updated to reference the new rollkitmngr module structure.


47-47: LGTM: Documentation consistently updated.

All function comments have been properly updated to reference the rollkitmngr module instead of the old sequencer module, maintaining accurate documentation.

Also applies to: 52-52, 62-62, 67-67

Makefile (1)

73-74: LGTM! Paths correctly updated for module rename.

The Makefile changes properly reflect the refactor from sequencer to rollkitmngr module, updating the protobuf generation paths accordingly.

modules/rollkitmngr/types/codec.go (2)

12-13: LGTM! Amino codec registrations updated correctly.

The legacy amino registrations properly reflect the new message types MsgMigrateToRollkit and MsgEditAttesters with the correct rollkitmngr/v1 namespace.


19-20: LGTM! Interface registry updated correctly.

The interface registry properly registers the new message types as implementations of sdk.Msg, maintaining consistency with the amino registrations.

modules/rollkitmngr/types/keys.go (1)

1-9:

✅ Verification successful

LGTM! Standard module key definitions.

The keys file follows Cosmos SDK conventions with clear naming and appropriate byte values for storage keys.

Please verify that the key values 0x13 and 0x14 don't conflict with any existing keys in the broader codebase:


🏁 Script executed:

#!/bin/bash
# Description: Check for potential key conflicts in the codebase
# Expected: No other modules using the same byte values for keys

echo "Searching for potential key conflicts with 0x13 and 0x14..."
rg "0x13|0x14" --type go -A 2 -B 2

Length of output: 7603


🏁 Script executed:

#!/bin/bash
echo "Searching for literal []byte{0x13} and []byte{0x14} outside .pb.go files..."
rg '\[\]byte\{0x13\}' -t go -g '!*.pb.go'
rg '\[\]byte\{0x14\}' -t go -g '!*.pb.go'

echo "Searching for MigrationKey and SequencerKey definitions across Go files..."
rg 'MigrationKey' -t go
rg 'SequencerKey' -t go

Length of output: 827


MigrationKey (0x13) and SequencerKey (0x14) are unique

Ripgrep across all Go files (excluding generated *.pb.go) shows these byte values only in

  • modules/rollkitmngr/types/keys.go (definitions)
  • referenced in modules/rollkitmngr/keeper/keeper.go

No conflicts detected.

modules/proto/rollkitsdk/rollkitmngr/module/v1/module.proto (4)

2-2: LGTM! Package name correctly updated.

The protobuf package name properly reflects the module rename from sequencer to rollkitmngr.


6-6: LGTM! Go package path updated correctly.

The Go package import path correctly reflects the new module structure.


11-11: LGTM! Go import directive updated correctly.

The go_import directive properly points to the new rollkitmngr module path.


4-4:

❌ Incorrect review comment

Fix missing import causing compilation error.

The static analysis correctly identifies that the imported file cosmos/app/v1alpha1/module.proto is not included in the imports section, which will cause protobuf compilation to fail.

The file references cosmos.app.v1alpha1.module in line 10 but doesn't import it. Add the missing import:

 import "cosmos/app/v1alpha1/module.proto";
+import "cosmos/app/v1alpha1/module.proto";

Wait, I see the import is already there on line 4. Let me verify this is a real issue by checking if the path exists in the dependencies:


🏁 Script executed:

#!/bin/bash
# Description: Check if the cosmos/app/v1alpha1/module.proto import exists
# Expected: Find the import file in dependencies or proto files

echo "Checking for cosmos/app/v1alpha1/module.proto in the codebase..."
fd -e proto -x grep -l "cosmos/app/v1alpha1/module.proto" {} \;

echo "Checking for any cosmos/app proto files..."
fd "cosmos" --type d | head -10

echo "Checking buf dependencies..."
cat modules/proto/buf.yaml 2>/dev/null || echo "No buf.yaml found"
cat modules/proto/buf.mod 2>/dev/null || echo "No buf.mod found"

Length of output: 1011


Import already present—no action needed

The import cosmos/app/v1alpha1/module.proto is already declared on line 4 of
modules/proto/rollkitsdk/rollkitmngr/module/v1/module.proto. There’s no missing import here, so no change is required. If you still encounter compilation errors, please ensure your Buf dependencies are properly fetched and that your build configuration is correct.

Likely an incorrect or invalid review comment.

🧰 Tools
🪛 Buf (1.54.0)

4-4: import "cosmos/app/v1alpha1/module.proto": file does not exist

(COMPILE)

modules/README.md (1)

4-4: Documentation accurately reflects expanded module scope.

The updated description correctly captures the enhanced functionality of the rollkitmngr module, expanding from just sequencers to include attesters and migration management.

modules/rollkitmngr/autocli.go (3)

1-1: Package and import path updates are correct.

The package rename from sequencer to rollkitmngr and the corresponding import path update properly reflect the module refactor.

Also applies to: 6-6


16-29: CLI commands properly reflect expanded module functionality.

The new CLI commands accurately represent the enhanced capabilities:

  • Attesters command for querying attesters (new functionality)
  • Sequencer command (renamed from plural to singular for consistency)
  • IsMigrating command for migration status (new functionality)

36-38: Authority gating for migration command is appropriate.

The MigrateToRollkit command is correctly marked as skipped due to authority gating, which is appropriate for governance-controlled migration operations.

modules/proto/rollkitsdk/rollkitmngr/v1/query.proto (3)

1-10: Protobuf file structure follows Cosmos SDK conventions.

The file header, package declaration, imports, and Go package option are correctly structured according to Cosmos SDK protobuf conventions.

🧰 Tools
🪛 Buf (1.54.0)

4-4: import "amino/amino.proto": file does not exist

(COMPILE)


12-27: Query service definition is well-structured.

The Query service properly defines the three RPC methods (IsMigrating, Sequencer, Attesters) with appropriate HTTP endpoint mappings. This aligns well with the CLI commands defined in autocli.go.


29-61: Request and response message types are properly defined.

The message types follow protobuf best practices:

  • Empty request types for simple queries
  • Well-documented response fields
  • Appropriate use of gogoproto and amino options for serialization
  • Consistent naming conventions
modules/proto/rollkitsdk/rollkitmngr/v1/types.proto (1)

12-16:

❓ Verification inconclusive

Verify intentional field numbering starting at 2.

The RollkitMigration message starts field numbering at 2, skipping field 1. This could indicate a reserved or deprecated field.


🏁 Script executed:

#!/bin/bash
# Description: Check if field 1 is reserved or if this is intentional

# Search for reserved fields in proto files
rg -A 2 -B 2 "reserved.*1" modules/proto/

# Check git history for removed field 1
git log -p --all -S "= 1;" -- "*.proto" | grep -A 5 -B 5 "RollkitMigration"

# Look for any comments about field reservation
rg -i "reserved|deprecated" modules/proto/rollkitsdk/rollkitmngr/

Length of output: 111


Confirm skipped field number in RollkitMigration

I didn’t find any reserved 1;, deprecated markers, or git history indicating a removed field 1 in modules/proto/rollkitsdk/rollkitmngr/v1/types.proto. Please verify that skipping field number 1 is intentional:

• File: modules/proto/rollkitsdk/rollkitmngr/v1/types.proto
Message: RollkitMigration (around line 12)
Current field:

uint64 block_height = 2;

If the omission was intentional, consider adding an explicit reservation or a comment for clarity, for example:

// Reserved for future use.
// reserved 1;

If not, renumber the field or restore the missing field definition.

modules/rollkitmngr/keeper/abci.go (2)

33-51: Well-implemented chain halt mechanism for migration completion.

The PreBlocker implementation correctly:

  • Checks for migration completion at exactly one block after the migration end
  • Removes migration state before halting to prevent repeated halts on restart
  • Provides clear error message for operators

This ensures a clean binary switch after migration completes.


53-79: Clean migration logic with appropriate IBC handling.

The EndBlock implementation properly:

  • Checks migration status and timing
  • Handles both IBC-enabled and non-IBC scenarios
  • Delegates to appropriate migration strategies (migrateNow vs migrateOver)
  • Includes proper error handling for state retrieval

The separation of immediate vs gradual migration based on IBC enablement is a good design choice.

modules/rollkitmngr/keeper/grpc_query.go (1)

44-53: LGTM!

The IsMigrating query implementation correctly delegates to the keeper and properly constructs the response.

modules/rollkitmngr/keeper/msg_server.go (1)

25-46: LGTM!

The MigrateToRollkit implementation correctly validates authority and block height, and properly handles the migration state storage.

modules/rollkitmngr/keeper/keeper.go (2)

72-76: LGTM!

The Logger method correctly implements the standard Cosmos SDK module logger pattern.


91-91:

✅ Verification successful

Verify IBCSmoothingFactor is properly imported.

The code references IBCSmoothingFactor which is not defined in this file. According to the relevant snippets, it's defined in migration.go.


🏁 Script executed:

#!/bin/bash
# Description: Verify IBCSmoothingFactor constant is defined and accessible

# Check if IBCSmoothingFactor is defined in the keeper package
rg -A 2 "IBCSmoothingFactor" modules/rollkitmngr/keeper/

# Check if it's exported (starts with uppercase)
ast-grep --pattern 'const IBCSmoothingFactor'

Length of output: 947


No action needed: IBCSmoothingFactor is defined in the same package
The IBCSmoothingFactor variable is declared in modules/rollkitmngr/keeper/migration.go as an exported uint64, so it’s accessible in keeper.go without additional imports.

modules/rollkitmngr/keeper/migration.go (1)

50-74: LGTM - Sequencer migration logic is correct.

The function properly handles single sequencer migration by removing all non-sequencer validators and adding/updating the sequencer with power 1.

[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// Sequencer defines a sequence of instructions to be executed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update misleading comment for Sequencer message.

The comment "defines a sequence of instructions to be executed" is misleading. In blockchain context, a sequencer is typically an entity that orders transactions, not a sequence of instructions.

-// Sequencer defines a sequence of instructions to be executed.
+// Sequencer defines an entity responsible for ordering and producing blocks.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Sequencer defines a sequence of instructions to be executed.
// Sequencer defines an entity responsible for ordering and producing blocks.
🤖 Prompt for AI Agents
In modules/proto/rollkitsdk/rollkitmngr/v1/types.proto at line 27, update the
comment for the Sequencer message to accurately reflect its role as an entity
that orders transactions in the blockchain context, rather than describing it as
a sequence of instructions to be executed. Replace the misleading comment with
one that clearly states the Sequencer's function in ordering transactions.

julienrbrt and others added 3 commits May 30, 2025 11:39
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@julienrbrt julienrbrt requested review from alpe and randygrok June 2, 2025 08:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad73f1b and 5d9a3c1.

📒 Files selected for processing (5)
  • modules/rollkitmngr/depinject.go (4 hunks)
  • modules/rollkitmngr/keeper/abci.go (1 hunks)
  • modules/rollkitmngr/keeper/grpc_query_test.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
  • modules/rollkitmngr/types/expected_keepers.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • modules/rollkitmngr/depinject.go
  • modules/rollkitmngr/keeper/abci.go
  • modules/rollkitmngr/keeper/keeper.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (8)
modules/rollkitmngr/types/expected_keepers.go (1)

12-12: LGTM! Interface method addition looks correct.

The new GetValidatorByConsAddr method follows Cosmos SDK conventions with proper context handling and return types. This addition supports the new Rollkit manager functionality for validator lookups by consensus address.

modules/rollkitmngr/keeper/grpc_query_test.go (7)

59-67: Test logic appears correct despite type mismatch.

The test logic for successful attester retrieval is well-structured, but it depends on fixing the type mismatch in the mock implementation identified earlier.


69-74: Good error handling test coverage.

The error case testing ensures proper error propagation from the underlying keeper.


76-86: Comprehensive migration state testing.

The test properly validates all three return values from the IsMigrating method, ensuring complete coverage of the migration state functionality.


88-96: Good coverage of migration blocking logic.

The test correctly verifies that sequencer queries return an error when migration is in progress.


98-110: Comprehensive success case testing.

The test properly sets up both the migration state (false) and sequencer data, ensuring the complete flow works correctly.


112-123: Proper error propagation testing.

The test ensures that errors from the underlying keeper are properly propagated to the query response.


48-53:

❌ Incorrect review comment

Verify query server dependencies.

The query server is created with only the keeper mock, but the Attesters tests use stakingKeeper. Ensure the query server implementation can access the staking keeper functionality through the keeper or needs both dependencies.


🏁 Script executed:

#!/bin/bash
# Check how the query server is implemented and what dependencies it needs
ast-grep --pattern 'func NewQueryServer($$$) $$$'

Length of output: 276


No additional QueryServer dependencies needed

The NewQueryServer constructor only accepts a single Keeper interface and returns queryServer{Keeper: keeper}. Passing just mockKeeper to NewQueryServer is correct:

  • QueryServer’s methods will invoke staking-related behavior through the Keeper interface.
  • If your Attesters tests require staking-specific responses, have mockKeeper implement (or delegate to) mockStakingKeeper internally rather than changing the constructor signature.

No changes to SetupTest or NewQueryServer are required.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
modules/rollkitmngr/keeper/grpc_query_test.go (1)

40-42: Previous type mismatch issue has been resolved.

The GetLastValidators method now correctly returns []stakingtypes.Validator as expected by the interface, resolving the compilation error mentioned in the previous review.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d525c67 and 75645e8.

📒 Files selected for processing (2)
  • modules/rollkitmngr/keeper/grpc_query_test.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/rollkitmngr/keeper/keeper.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (1)
modules/rollkitmngr/keeper/grpc_query_test.go (1)

89-159: Excellent test coverage and structure.

The test suite provides comprehensive coverage of all query methods with proper success and error case testing. The tests follow Go testing best practices with good use of the fixture pattern and clear assertions.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
modules/rollkitmngr/keeper/keeper.go (2)

44-47: Consider returning error instead of panicking.

While panicking for invalid authority is common in Cosmos SDK modules, consider whether this should return an error instead to allow callers to handle the failure gracefully, especially in testing scenarios.

-	// ensure that authority is a valid account address
-	if _, err := addressCodec.StringToBytes(authority); err != nil {
-		panic("authority is not a valid acc address")
-	}
+	// ensure that authority is a valid account address
+	if _, err := addressCodec.StringToBytes(authority); err != nil {
+		return Keeper{}, fmt.Errorf("authority is not a valid acc address: %w", err)
+	}

115-134: Review the defer/recover pattern for IBC detection.

While the approach of using defer/recover to detect IBC store existence is creative, it's somewhat unconventional. The pattern is correct but could be made more explicit about the expected panic behavior.

Consider adding a comment explaining that GetKVStore is expected to panic if the store doesn't exist, making the behavior more explicit:

 func (k Keeper) isIBCEnabled(ctx context.Context) (enabled bool) {
 	if k.ibcStoreKey == nil {
 		return false
 	}
 
 	sdkCtx := sdk.UnwrapSDKContext(ctx)
 
 	ms := sdkCtx.MultiStore().CacheMultiStore()
 	defer func() {
 		if r := recover(); r != nil {
-			// If we panic, it means the store does not exist, so IBC is not enabled.
+			// GetKVStore panics if the store key is not registered, indicating IBC is not enabled.
 			enabled = false
 		}
 	}()
+	// This will panic if the IBC store key is not registered in the multistore
 	ms.GetKVStore(k.ibcStoreKey)
 
 	enabled = true // has not panicked, so store exists
 
 	return
 }
modules/rollkitmngr/keeper/msg_server_test.go (1)

115-133: Consider adding more comprehensive success test cases.

While the success test is good, consider adding test cases that verify:

  1. Multiple valid attesters
  2. Attesters with different validator descriptions
  3. Edge cases with maximum allowed attesters
func TestEditAttesters_MultipleValidAttestersSuccess(t *testing.T) {
	s := initFixture(t)
	auth := sdk.AccAddress(address.Module(types.ModuleName)).String()
	
	pubkey1 := dummyConsensusPubkeyAny()
	pubkey2 := dummyConsensusPubkeyAny()
	
	s.stakingKeeper.vals = []stakingtypes.Validator{
		{
			Description:     stakingtypes.NewDescription("validator1", "", "", "", ""),
			ConsensusPubkey: pubkey1,
		},
		{
			Description:     stakingtypes.NewDescription("validator2", "", "", "", ""),
			ConsensusPubkey: pubkey2,
		},
	}

	msg := &types.MsgEditAttesters{
		Authority: auth,
		Attesters: []types.Attester{
			{Name: "attester1", ConsensusPubkey: pubkey1},
			{Name: "attester2", ConsensusPubkey: pubkey2},
		},
	}
	resp, err := s.msgServer.EditAttesters(s.ctx, msg)
	require.NoError(t, err)
	require.NotNil(t, resp)
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75645e8 and 53c0a0f.

📒 Files selected for processing (4)
  • modules/rollkitmngr/depinject.go (4 hunks)
  • modules/rollkitmngr/keeper/grpc_query_test.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
  • modules/rollkitmngr/keeper/msg_server_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/rollkitmngr/depinject.go
  • modules/rollkitmngr/keeper/grpc_query_test.go
🧰 Additional context used
🧬 Code Graph Analysis (2)
modules/rollkitmngr/keeper/msg_server_test.go (1)
modules/rollkitmngr/types/keys.go (1)
  • ModuleName (4-4)
modules/rollkitmngr/keeper/keeper.go (4)
modules/rollkitmngr/types/expected_keepers.go (1)
  • StakingKeeper (11-15)
modules/rollkitmngr/types/types.pb.go (6)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
modules/rollkitmngr/types/keys.go (3)
  • SequencerKey (8-8)
  • MigrationKey (7-7)
  • ModuleName (4-4)
modules/rollkitmngr/keeper/migration.go (1)
  • IBCSmoothingFactor (14-14)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint / golangci-lint
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (6)
modules/rollkitmngr/keeper/keeper.go (2)

17-19: Good design pattern for dependency injection.

The IbcStoreKeyAlias type alias is a clever solution to work around depinject's limitation of one store key per module while maintaining clean dependency injection.


99-99:

❌ Incorrect review comment

Verify IBCSmoothingFactor constant availability.

The code references IBCSmoothingFactor but it's not imported or defined in this file. Ensure this constant is properly accessible.


🏁 Script executed:

#!/bin/bash
# Description: Verify IBCSmoothingFactor is defined and accessible in the rollkitmngr package
# Expected: Should find the constant definition

ast-grep --pattern 'IBCSmoothingFactor'

Length of output: 223


IBCSmoothingFactor is already defined in this package

The constant IBCSmoothingFactor is declared in modules/rollkitmngr/keeper/migration.go and is in the same package, so no import is needed.

Likely an incorrect or invalid review comment.

modules/rollkitmngr/keeper/msg_server_test.go (4)

16-20: Good helper function for test data generation.

The dummyConsensusPubkeyAny() helper provides a clean way to generate test consensus public keys using ed25519, which is appropriate for testing scenarios.


69-87: Excellent test coverage for duplicate key validation.

This test properly validates that duplicate consensus public keys are rejected, which is crucial for maintaining attester uniqueness. The test setup with mock validator data is well-structured.


89-100: Good edge case testing for invalid public key types.

Testing with an invalid Any type URL ensures the message server properly validates consensus public key formats, preventing potential runtime errors.


22-28:

❌ Incorrect review comment

Verify initFixture function availability.

The tests reference initFixture(t) which is not defined in this file. Ensure this test fixture setup function exists and is properly configured.


🏁 Script executed:

#!/bin/bash
# Description: Find the initFixture function definition used in tests
# Expected: Should find the fixture setup in a test helper file

ast-grep --pattern 'func initFixture($$$) $$$'

Length of output: 2201


🏁 Script executed:

#!/bin/bash
# Show the beginning of msg_server_test.go to inspect package declaration and imports
head -n 20 modules/rollkitmngr/keeper/msg_server_test.go

Length of output: 646


🏁 Script executed:

#!/bin/bash
# Inspect package declaration in grpc_query_test.go
head -n 5 modules/rollkitmngr/keeper/grpc_query_test.go

Length of output: 107


Ignore missing initFixture suggestion

The initFixture(tb testing.TB) helper is already defined in modules/rollkitmngr/keeper/grpc_query_test.go under the same keeper_test package, so it’s correctly referenced in msg_server_test.go.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
modules/rollkitmngr/keeper/keeper.go (1)

114-136: Clever IBC detection approach, but consider architectural implications.

The defer/recover pattern to detect IBC store existence is unconventional but well-documented and safe. However, this creates a tight coupling between the rollkitmngr module and IBC's internal store structure.

Consider if this logic could be moved to a configuration parameter or dependency injection to make it more explicit and testable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 916c424 and fbd3e03.

📒 Files selected for processing (3)
  • modules/rollkitmngr/depinject.go (4 hunks)
  • modules/rollkitmngr/keeper/grpc_query_test.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/rollkitmngr/depinject.go
  • modules/rollkitmngr/keeper/grpc_query_test.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
modules/rollkitmngr/keeper/keeper.go (4)
modules/rollkitmngr/types/expected_keepers.go (1)
  • StakingKeeper (11-15)
modules/rollkitmngr/types/types.pb.go (6)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
modules/rollkitmngr/types/keys.go (3)
  • SequencerKey (8-8)
  • MigrationKey (7-7)
  • ModuleName (4-4)
modules/rollkitmngr/keeper/migration.go (1)
  • IBCSmoothingFactor (14-14)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (5)
modules/rollkitmngr/keeper/keeper.go (5)

18-34: Well-structured keeper implementation.

The type definitions follow Cosmos SDK best practices, and the use of collections for state management is excellent. The IBC store key alias is a clever workaround for depinject limitations.


36-79: Solid constructor implementation.

The constructor properly validates inputs, follows Cosmos SDK conventions for error handling, and correctly initializes the collections schema.


81-85: Standard logger implementation.

Follows Cosmos SDK conventions correctly.


107-109: Integer overflow issue has been addressed.

Good fix! The previous concern about integer overflow in block height comparison has been properly addressed by converting sdkCtx.BlockHeight() to uint64 before comparison.


100-100:

❌ Incorrect review comment

Missing import or definition for IBCSmoothingFactor.

The code references IBCSmoothingFactor but it's not imported or defined in this file. Based on the relevant code snippets, it appears to be defined in modules/rollkitmngr/keeper/migration.go. This will cause a compilation error.

You need to either:

  1. Import the constant from the migration package
  2. Move the constant to the types package
  3. Define it locally in this file

🏁 Script executed:

#!/bin/bash
# Verify if IBCSmoothingFactor is accessible from this file
rg -A 2 -B 2 "IBCSmoothingFactor" --type go

Length of output: 1438


Ignore missing import for IBCSmoothingFactor

The IBCSmoothingFactor constant is declared in modules/rollkitmngr/keeper/migration.go (same package), so it’s in scope and does not need to be imported. The integer-overflow concern has already been addressed by converting heights to uint64.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
modules/rollkitmngr/keeper/keeper.go (1)

121-143: Consider documenting the panic recovery approach.

The panic recovery mechanism to detect IBC store existence is functional but unconventional. Consider adding a comment explaining why this approach is used instead of a more direct method.

	ms := sdkCtx.MultiStore().CacheMultiStore()
	defer func() {
		if r := recover(); r != nil {
-			// If we panic, it means the store does not exist, so IBC is not enabled.
+			// If we panic, it means the store does not exist, so IBC is not enabled.
+			// This approach avoids importing IBC modules directly.
			enabled = false
		}
	}()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbd3e03 and 6f03fb3.

📒 Files selected for processing (5)
  • modules/rollkitmngr/keeper/abci.go (1 hunks)
  • modules/rollkitmngr/keeper/abci_test.go (1 hunks)
  • modules/rollkitmngr/keeper/keeper.go (1 hunks)
  • modules/rollkitmngr/keeper/migration.go (1 hunks)
  • modules/rollkitmngr/types/keys.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • modules/rollkitmngr/keeper/abci_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/rollkitmngr/types/keys.go
  • modules/rollkitmngr/keeper/abci.go
🧰 Additional context used
🧠 Learnings (1)
modules/rollkitmngr/keeper/migration.go (2)
Learnt from: julienrbrt
PR: rollkit/go-execution-abci#114
File: modules/rollkitmngr/keeper/migration.go:13-14
Timestamp: 2025-05-30T09:40:24.067Z
Learning: In modules/rollkitmngr/keeper/migration.go, the IBCSmoothingFactor variable is intentionally mutable (not a constant) to allow different chains to modify the smoothing period for IBC migration based on their specific requirements.
Learnt from: julienrbrt
PR: rollkit/go-execution-abci#114
File: modules/rollkitmngr/keeper/migration.go:18-46
Timestamp: 2025-05-30T09:43:01.067Z
Learning: In the rollkitmngr module migration functions, input validation for migration data parameters (like checking if Sequencer.ConsensusPubkey is nil) is not needed according to the project maintainer's preference.
🧬 Code Graph Analysis (2)
modules/rollkitmngr/keeper/keeper.go (4)
modules/rollkitmngr/types/expected_keepers.go (1)
  • StakingKeeper (11-15)
modules/rollkitmngr/types/types.pb.go (6)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
modules/rollkitmngr/types/keys.go (4)
  • SequencerKey (8-8)
  • MigrationKey (7-7)
  • MigrationStepKey (9-9)
  • ModuleName (4-4)
modules/rollkitmngr/keeper/migration.go (1)
  • IBCSmoothingFactor (16-16)
modules/rollkitmngr/keeper/migration.go (2)
modules/rollkitmngr/keeper/keeper.go (1)
  • Keeper (22-35)
modules/rollkitmngr/types/types.pb.go (9)
  • RollkitMigration (30-39)
  • RollkitMigration (43-43)
  • RollkitMigration (44-46)
  • Sequencer (96-102)
  • Sequencer (106-106)
  • Sequencer (107-109)
  • Attester (152-158)
  • Attester (162-162)
  • Attester (163-165)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (7)
modules/rollkitmngr/keeper/keeper.go (3)

22-35: Well-designed keeper structure with proper state management.

The Keeper struct properly encapsulates all necessary dependencies and uses collections for type-safe state management. The inclusion of both required dependencies (storeService, cdc, authority) and optional ones (ibcStoreKey) provides good flexibility.


37-86: Robust constructor with proper validation and error handling.

The constructor correctly validates the authority address and sets up collections with appropriate error handling. The panic on schema build failure is appropriate for a constructor.


94-119: Migration timing logic correctly implemented.

The migration timing logic properly handles both IBC and non-IBC scenarios with appropriate smoothing factors. The type conversion from int64 to uint64 at line 115 correctly addresses potential overflow concerns from previous reviews.

modules/rollkitmngr/keeper/migration.go (4)

18-48: Clean migration orchestration with proper error handling.

The migrateNow function properly orchestrates between sequencer-only and attester migration modes. Error wrapping provides good context, and storing the sequencer state is correctly handled.


50-76: Correct sequencer migration logic.

The function properly removes all existing validators except the new sequencer and adds the sequencer with power 1. The logic correctly skips removing the sequencer if it's already in the validator set.


78-113: Improved attester migration logic addresses previous issues.

The function correctly separates the logic for removing non-attester validators and adding new attesters, fixing the nested loop issue from previous reviews. The use of a map for efficient lookup is well-implemented.


115-205:

✅ Verification successful

Complex but well-structured gradual migration logic.

The migrateOver function implements sophisticated logic for gradual validator set changes to maintain IBC light client compatibility. The step-based approach with proper bounds checking and state persistence is well-designed.

However, verify the integer division logic for edge cases:


🏁 Script executed:

#!/bin/bash
# Verify the integer division logic doesn't cause issues with small validator sets
echo "Testing division logic for edge cases:"
echo "Case 1: 1 validator, 30 steps: $((1 + 30 - 1) / 30) = $(((1 + 30 - 1) / 30)) validators per step"
echo "Case 2: 29 validators, 30 steps: $((29 + 30 - 1) / 30) = $(((29 + 30 - 1) / 30)) validators per step"  
echo "Case 3: 31 validators, 30 steps: $((31 + 30 - 1) / 30) = $(((31 + 30 - 1) / 30)) validators per step"

Length of output: 1194


Complex but well-structured gradual migration logic – integer‐division logic verified

The migrateOver function uses

removePerStep := (len(oldValsToRemove) + int(IBCSmoothingFactor) - 1) / int(IBCSmoothingFactor)

to compute a ceiling division and ensure at least one validator is removed each step when any remain. I confirmed this yields the expected values for edge cases (1→1, 29→1, 31→2 with a 30-step smoothing factor). No issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional Rollkit SDK modules
1 participant